<?php


namespace app\api\controller\v1;


use app\common\controller\UserBaseController;
use app\api\model\ArticleCateModel;

class ArticleCateController extends UserBaseController
{
    function addAction() {
        $this->paramlist = array(
            'token' => 'string',
            'name' => 'string',
            'rank' => 'int',
            'visitable' => 'int',
            'icon' => 'string',
        );

        $this->check_params();
        $this->check_token();


        (new ArticleCateModel())->add($this->argv);

        return $this->ret_resp();
    }

    function delAction()
    {
        $this->paramlist = array(
            'token' => 'string',
            'id' => 'int',
        );

        $this->check_params();
        $this->check_token();

        $data = [
            'state' => -1,
        ];
        (new ArticleCateModel())->update_article($this->argv['id'], $data);

        return $this->ret_resp();
    }

    function updateAction() {
        $this->paramlist = array(
            'token' => 'string',
            'id' => 'int',
            'name' => 'string',
            'rank' => 'int',
            'visitable' => 'int',
            'icon' => 'string',
        );

        $this->check_params();
        $this->check_token();


        (new ArticleCateModel())->update_article($this->argv['id'], $this->argv);

        return $this->ret_resp();
    }
}